import Vue from 'vue'
import VueRouter from 'vue-router'



Vue.use(VueRouter);


const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};
const router = new VueRouter({
  mode: 'history',
  routes:[
    {
      path: '/',
      name: 'login',
      component: resolve => require(['../view/Login'], resolve),
    },
    {
      path: '/home',
      name:'home',
      component:resolve => require(['../view/Home'], resolve),
      children:[
        {
          path:'/user',
          name:'user',
          component:resolve => require(['../view/user/User'], resolve),
        },
        {
          path:'/data',
          name:'data',
          component:resolve => require(['../view/data/Data'], resolve),
        },
        {
          path:'/demands',
          name:'demands',
          component:resolve => require(['../view/demands/Demands'], resolve),
        },
        {
          path:'/demandsCategory',
          name:'demandsCategory',
          component:resolve => require(['../view/demands/DemandsCategory'], resolve),
        },
        {
          path:'/addOrder',
          name:'addOrder',
          component:resolve => require(['../view/orders/AddOrder'], resolve),
        },
        {
          path:'/orderComments',
          name:'orderComments',
          component:resolve => require(['../view/orders/OrderComments'], resolve),
        },
        {
          path:'/orders',
          name:'orders',
          component:resolve => require(['../view/orders/Orders'], resolve),
        },
        {
          path:'/rights',
          name:'rights',
          component:resolve => require(['../view/power/Rights'], resolve),
        },
        {
          path:'/addWork',
          name:'addWork',
          component:resolve => require(['../view/works/AddWork'], resolve),
        },{
          path:'/user',
          name:'user',
          component:resolve => require(['../view/user/User'], resolve),
        },
        {
          path:'/workComments',
          name:'workComments',
          component:resolve => require(['../view/works/WorkComments'], resolve),
        },
        {
          path:'/worksInfo',
          name:'worksInfo',
          component:resolve => require(['../view/works/WorksInfo'], resolve),
        },
        {
          path:'/worksInfoCategory',
          name:'worksInfoCategory',
          component:resolve => require(['../view/works/WorksInfoCategory'], resolve),
        },
        {
          path:'/demandFormat',
          name:'demandFormat',
          component:resolve => require(['../view/demands/demandFormat'], resolve),
        },

      ]
    }
  ]

});


export default router

